﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ABCat.Plugins.FilteringLogics.Standard
{
	/// <summary>
	/// Interaction logic for AutoFilterCmb.xaml
	/// </summary>
	public partial class AutoFilterCmb
	{
		#region + Ctor +

		public AutoFilterCmb()
		{
			InitializeComponent();
			Items.Filter = FilterPredicate;
			IsEditable = true;
		}

		#endregion
		#region + Logic +

		private bool FilterPredicate(object obj)
		{
			var text = obj as string;
			string filterText = Text;
			if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(filterText))
			{
				if (text.Contains(filterText))
				{
					return true;
				}
				return false;
			}
			return string.IsNullOrEmpty(filterText);
		}

		#endregion
	}
}
